import 'package:flutter/material.dart';

import '../bean/home_bean.dart';

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: const Text("首页"),
        actions: [
          IconButton(icon: const Icon(Icons.settings), onPressed: () {})
        ],
      ),
      body: ListView.builder(
          itemCount: homeListBean.length,
          itemBuilder: (context, index) {
            var item = homeListBean[index];
            return itemList(item);
          }),
    );
  }

  Widget itemList(HomeBean homeBean) {
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: Card(
        shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(20.0))),
        elevation: 5,
        clipBehavior: Clip.antiAlias,
        child: Container(
          width: double.maxFinite,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.start,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Image.network(
                homeBean.image,
                height: 200,
                width: double.maxFinite,
                fit: BoxFit.fitWidth,
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Text(homeBean.title),
              ),
              Padding(
                padding: const EdgeInsets.only(left: 8, bottom: 8),
                child: Text(homeBean.context),
              )
            ],
          ),
        ),
      ),
    );
  }
}
